﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_GetParentTreeBasicReference')
	BEGIN
		DROP  Procedure  esf_sso.P_GetParentTreeBasicReference
	END
GO


CREATE Procedure esf_sso.P_GetParentTreeBasicReference
(
	@pBasicReferenceID INT
	,@pBasicReferenceTypeID INT
)
AS
	SELECT
		TOP 1
		VBR.*
	FROM
		esf_sso.VBasicReference VBR
	INNER JOIN
		esf_sso.TreeBasicReference TBR ON
			TBR.ParentBasicReferenceID = VBR.ID
	WHERE
		TBR.BasicReferenceID = @pBasicReferenceID
		AND VBR.BasicReferenceTypeID = @pBasicReferenceTypeID
